/** m2settings is a GUI to configure Maven 2 settings.xml
 *
 *  Copyright (C) 2007 Regis Decamps <decamps@users.sf.net>
 *
 *  This file is part of m2settings.
 *
 *  m2settings is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  Foobar is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Foobar; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *  or read it online http://www.gnu.org/licenses/gpl.txt
 *
 **/
/*
 * Mirror.java
 *
 * Created on April 22, 2007, 12:54 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package info.decamps.m2settings.beans;

import info.decamps.m2settings.model.Mirror;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.lang.StringUtils;

/**
 *
 * @author regis decamps (decamps@users.sf.net)
 */
public class MyMirror  {
    Mirror mirror;
    /** Creates a new instance of Mirror with default values. */
    public MyMirror() {
        this.mirror=new Mirror();
        setMirrorOf("central");
    }
    public MyMirror(info.decamps.m2settings.model.Mirror parent) {
        this.mirror=parent;
    }
    public Mirror getMirror() {
        return mirror;
    }
    
    public String getId() {
        return mirror.getId();
    }
    
    public String getMirrorOf() {
        return mirror.getMirrorOf();
    }
    
    public String getName() {
        return mirror.getName();
    }
    
    public String getUrl() {
        return mirror.getUrl();
    }
    
    public void setUrl(String url) throws MalformedURLException {
        if (StringUtils.isBlank(url)) {
            mirror.setUrl(null);
            return;
        }
        URL u=new URL(url);
        mirror.setUrl(url);
    }
    
    public void setMirrorOf(String mirrorOf) {
        if (StringUtils.isBlank(mirrorOf))
            mirrorOf=null;
        mirror.setMirrorOf(mirrorOf);
    }
    
    public void setId(String id) {
        mirror.setId(id);
    }
    
    public void setName(String name) {
        if (StringUtils.isBlank(name))
            name=null;
        mirror.setName(name);
    }
}